package com.bdqn.tour.servlet.Gyh;

import com.bdqn.tour.service.GyhDeleteUserInfoService;
import com.bdqn.tour.service.impl.GyhDeleteUserInfoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 删除用户信息
 */
@WebServlet("/gyhDeleteUserInfo")
public class GyhDeleteUserInfoServlrt extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置字符编码
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        //获取参数
        int id = Integer.parseInt(req.getParameter("id"));
        //调用service层业务删除用户信息
        GyhDeleteUserInfoService service = new GyhDeleteUserInfoServiceImpl();
        //调用业务层删除用户信息的方法
        int result = service.deleteUserInfo(id);
        //向客户端直接输出result结果交给jsp页面判断得出相应结果
        resp.getWriter().print(result);
        //关闭字符输出流
        resp.getWriter().close();

    }
}
